import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: HomeView
    },
    {
      path: '/about',
      name: 'about',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/AboutView.vue')
    },
    { 
      path: '/echarts', 
      name: 'echarts',
      component: () => import('../views/drawEcharts/index.vue') 
    },
    { 
      path: '/test', 
      name: 'test',
      component: () => import('../views/test/index.vue') },

    { 
      path: '',
      name: '',
      redirect: '/welcome' },
    { path: 
      '/welcome',
      name: 'welcome',
      component: () => import('../views/welcome.vue') 
    },
    { 
      path: '/404', 
      name: '404',
      component: () => import('../views/404.vue') 
    },
    { path: '/canvas', component: () => import('../views/drawCanvas/index.vue') },
    { path: '/css', component: () => import('../views/cssEffect/index.vue') },
    {
      path: '/others', component: () => import('../views/otherPages/index.vue'),
      redirect: '/tools',
      children: [
          { path: '/tools', component: () => import('../views/otherPages/tools.vue') },
          { path: '/study', component: () => import('../views/otherPages/study.vue') },
          { path: '/blog', component: () => import('../views/otherPages/blog.vue') },
          { path: '/edit', component: () => import('../views/otherPages/edit.vue') },
          { path: '/loadmd/:name', component: () => import('../views/otherPages/loadmd.vue') },

      ]
    },
  ]
})

export default router
